<!DOCTYPE html>
<html>
{include file="public/header" /}
<body>


<div class="layui-fluid" id="app" style="margin-top: 0px">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card" >

                <div class="layui-card-body">
                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                        <ul class="layui-tab-title">
                            <li class="layui-this" style="">品牌列表</li>
                            <li onclick="go('newpinpai')">新增品牌</li>
                        </ul>
                        <div class="layui-tab-content" style="padding-left: 0px;padding-right: 0px">

                            <div class="layui-tab-item layui-show">


                                <div class="layadmin-trailer ">


                                    <table class="layui-table" lay-skin="line">

                                        <thead>
                                        <tr>
                                            <!--<th></th>-->
                                            <th>#ID</th>
                                            <th>名称</th>
                                            <th></th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="(item,index) in items" :data_id="item.id" id="tr">
                                            <!--<td style="width: 20px;text-align: center">-->
                                                <!--<input type="radio" class="vue_index" name="id" :value="index"-->
                                                       <!--style="zoom: 150%" >-->
                                            <!--</td>-->
                                            <td>{{item.id}}</td>
                                            <td onclick="gettext()">{{item.pinpai}}</td>
                                            <td><div class="layui-btn-group" >
                                                <button class="layui-btn" :data_index="index" onclick="sure(this);" style="height: 30px;line-height: 30px">确定</button>
                                            </div></td>
                                        </tr>

                                        </tbody>
                                    </table>


                                </div>
                                <div id="demo7"></div>

                            </div>


                        </div>
                    </div>


                </div>


            </div>

        </div>


    </div>
</div>


<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>

    var app = new Vue({
        el: '#app',
        data: {
            check: [],
            // text:"",
            curr: 1,//当前页
            limit: 10,//当前页
            items: []
        }
    });

    function init() {
        layer.ready(function () {
            layer.load(2);
            $.get('/admin/goods/selectpinpai', {page: app.curr, limit: app.limit},
                function (res) {
                    layer.closeAll();
                    app.items = res.data;
                }
            );
        });

    }
    layui.use('table', function () {
        var table = layui.table;
    });

    //获取下标
    function getradio() {
        var check = [];
        $.each($('input[type=radio]:checked.vue_index'), function () {
            check.push($(this).val());
        });
        return check;
    }
    //确定选中，向父页面传入id 和品牌的值
    function sure(that) {
        // var item=getradio();
        var data_index = $(that).attr('data_index');
        var item=data_index;
        var pp=app.items[item];
        // console.log(pp.id);
        // console.log(pp.pinpai);
        parent.selectpp(pp.id,pp.pinpai);
        parent.layer.closeAll();

    }
    //添加品牌页面
    layui.$('#newpinpai').on('click', function () {

        layer.load(2);
        location.href = "{:url('newpinpai')}";
    });



    layui.use(['laypage', 'layer'], function () {
        var laypage = layui.laypage
            , layer = layui.layer;
        //完整功能
        laypage.render({
            elem: 'demo7'
            , count: "{$count}"
            , limits: [10, 20]
            , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            , jump: function (obj) {
                console.log(obj)
                app.curr = obj.curr;
                app.limit = obj.limit;
                init();

            }
        });

    });
    // //新增品牌弹窗
    // function addpinpai(that) {
    //
    //     var data_id = $(that).attr('data_id');
    //     layer.open({
    //
    //         type: 2,
    //         title: '新增',
    //         shadeClose: true,
    //         shade: 0.01,
    //         area: ['80%', '80%'],
    //         content: "{:url('addpinpai')}?id=" + data_id //iframe的url
    //
    //     });
    //
    // }

</script>


</body>
</html>




